<?php
use yii\db\Migration;

class m151119_085827_modularity extends Migration
{

    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }
        
        $this->createTable('{{%modularity}}', [
            'id' => $this->string(64)
                ->notNull(),
            'is_system' => $this->boolean()
                ->notNull()
                ->defaultValue(false),
            'enable_backend' => $this->boolean()
                ->notNull()
                ->defaultValue(false),
            'enable_frontend' => $this->boolean()
                ->notNull()
                ->defaultValue(false),
            'enable_api' => $this->boolean()
                ->notNull()
                ->defaultValue(false),
            'sort' => $this->smallInteger(2)
                ->notNull()
                ->defaultValue(0)
        ], $tableOptions);
        
        $this->addPrimaryKey('pk_id', '{{%modularity}}', 'id');
    }

    public function safeDown()
    {
        $this->dropTable('{{%modularity}}');
    }
}
